<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=yes">
<title>天天惠</title>
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
<link rel="stylesheet" type="text/css" href="/static/css/shoujisc.css">
<link rel="stylesheet" type="text/css" href="/static/css/jquery.mobile-1.4.5.min.css">
<link rel="stylesheet" type="text/css" href="/static/css/my.css">
<script type="text/javascript" src="/static/js/jquery-2.0.0.min.js"></script>

<script type="text/javascript" src="/static/js/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="/static/js/myinit.js"></script>
<style type="text/css">
.ui-input-text {
	height: 32px;
	padding-top: 0px;
	padding-bottom: 0px;
	border: 1px solid #FFB366;
}
.myserch {
	display: inline-block;
	margin-right: 50px;
	margin-left: 50px;
	margin-top: 8px;
}
.ui-input-text input {
	height: 32px;
	line-height: 32px;
	font-size: 14px;
	padding: 0px 0px 0px 0px;
}

.mystars{
}


</style>
<script type="text/javascript">

</script>
</head>
<body>

<div data-role="page" id="pingjia">
	<div data-role="header" style="background-color:white;border-bottom-width: 1px;top:0px;text-shadow:none">
		<a style="background-image:url('data:image/svg+xml;charset=US-ASCII,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22iso-8859-1%22%3F%3E%3C!DOCTYPE%20svg%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20SVG%201.1%2F%2FEN%22%20%22http%3A%2F%2Fwww.w3.org%2FGraphics%2FSVG%2F1.1%2FDTD%2Fsvg11.dtd%22%3E%3Csvg%20version%3D%221.1%22%20id%3D%22Layer_1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20x%3D%220px%22%20y%3D%220px%22%20%20width%3D%2214px%22%20height%3D%2214px%22%20viewBox%3D%220%200%2014%2014%22%20style%3D%22enable-background%3Anew%200%200%2014%2014%3B%22%20xml%3Aspace%3D%22preserve%22%3E%3Cpolygon%20points%3D%2210.596%2C11.949%205.646%2C7%2010.596%2C2.05%208.475%2C-0.071%201.404%2C7%208.475%2C14.07%20%22%2F%3E%3C%2Fsvg%3E');background-repeat:no-repeat;background-position:center;border:none;background-color:transparent;box-shadow: none;margin-top: 1px;" onclick="javascript:window.history.go(-1)"><span style="visibility:hidden">返</span></a>
		<h1>评价晒单</h1>
		<button class="ui-btn" style="background:transparent;border:none;box-shadow:none;margin-top: 1px;color:#f23949" id="cmf">提交</button>
	</div>
	
	
	
	
  <!--reallbody start  -->
  
  
  
  
	<div role="main" class="ui-content">
		<div style="background-color:white;background-position:10px 10px;background-repeat:no-repeat;background-size:auto 100px;height:120px;" id="goods_img">
			 
			<div style="padding-top:20px;padding-left:140px">
				<h1>评分</h1>
				
				<div class="mystars" id="goodpingjia" style="margin-top:20px">
					<img src="/static/img/star_dark.png" style="display:inline-block" height="auto" width="30px">
					<img src="/static/img/star_dark.png" style="display:inline-block" height="auto" width="30px">
					<img src="/static/img/star_dark.png" style="display:inline-block" height="auto" width="30px">
					<img src="/static/img/star_dark.png" style="display:inline-block" height="auto" width="30px">
					<img src="/static/img/star_dark.png" style="display:inline-block" height="auto" width="30px">
				</div>
			</div>
		
		</div>
		
		<textarea style="border-radius:0px;background-color:transparent" placeholder="写下购物体会和使用感受来帮助其他小伙伴~" maxlength="200"></textarea>
		
		<div style="height:44px;background:white">
			<span style="color:grey;font-size:14px;float:right;line-height:44px;margin-right:4px;">满意请给5星哦</span>
			<h1 style="font-weight:normal;line-height:44px;margin-left:4px">物流服务评价</h1>
		
		
		
		</div>
		<div id="shangpingbaozhuang" style="height:44px;background:white;line-height:44px;margin-top:1px;;padding-left:4px;padding-right:6px">
			<span class="mystars" style="float:right;">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
					 
					 
					 
					 
			</span>
			商品包装
		</div>
		<div id="songhuosudu" style="height:44px;background:white;line-height:44px;padding-left:4px;padding-right:6px">
			<span class="mystars" style="float:right;">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
					 
					 
					 
					 
			</span>
			送货速度
		</div>
		<div id="songhuyuanfuwutaidu" style="height:44px;background:white;line-height:44px;padding-left:4px;padding-right:6px">
			<span class="mystars" style="float:right;">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
				<img src="/static/img/star_dark.png" style="display:inline-block;vertical-align: middle;" height="24px" width="auto">
					 
					 
					 
					 
			</span>
			送货员服务态度
		</div>
	</div>
	
	
	
	
	
	
		 
</div>

<script type="text/javascript">
var oid = getUrldata('ORDERID');
var goodid = getUrldata('GOODID');
var openid=getUrldata('OPENID');

$('.mystars').each(function(index,item){
	var aa=$(this);
	aa.find('img').each(function(i,element){
		$(this).click(function(){
			aa.find('img:lt('+(i+1)+')').attr('src',"/static/img/star_light.png");
			aa.find('img:gt('+i+')').attr('src',"/static/img/star_dark.png");
		
		});
	
	});

});

function initThisGood(){
	var url="/webserver/api/v1/good/?format=json&id="+goodid;
	$.getJSON(url,function(rs){
		var gd=rs.objects[0];
		$('#goods_img').css('background-image','url("'+gd.image_thumb+'")');
	});
}
$('#cmf').click(function(){
	if($('#shangpingbaozhuang').find('img[src="/static/img/star_light.png"]').length==0){
		alert('请为商品包装做评价!');
		return;
	}
	if($('#goods_img').find('img[src="/static/img/star_light.png"]').length==0){
		alert('请为商品做评价!');
		return;
	}
	if($('#songhuosudu').find('img[src="/static/img/star_light.png"]').length==0){
		alert('请为送货速度做评价!');
		return;
	}
	if($('#songhuyuanfuwutaidu').find('img[src="/static/img/star_light.png"]').length==0){
		alert('请为送货员服务态度做评价!');
		return;
	}
	
	if($('textarea').val()==''){
		alert('评价内容不能为空');
		return;
	}
	pingjia();
});

$(document).on('pagebeforeshow','#pingjia',function(){
	initThisGood();

});


function pingjia(){
	var aa={};
	var url ="/webserver/api/v1/custassess/";
	/*
	  // url = 'http://127.0.0.1:8000/webserver/api/v1/custassess/'
    data = {"assesscont": "不错2232322","goods":'/webserver/api/v1/good/14/',"order":'/webserver/api/v1/order/30/', "wx_id": "aaaaaaaaa"}
    其中"goods":'/webserver/api/v1/good/14/'中的14代表good的id为14的商品。由此可以通过改变这个值，来实现对不同商品的评价提交
"order":'/webserver/api/v1/order/30/'中的30代表order的id为30的订单

	//{"assesscont": "不错2232322", "goods":'/webserver/api/v1/good/1/', "wx_id": //"aaaaaaaaa"}
	*/
	aa.assesscont=$('textarea').val();
	aa.goods='/webserver/api/v1/good/'+goodid+"/";
	aa.wx_id=openid;
	aa.order='/webserver/api/v1/order/'+oid+'/';
	
	aa.good_grade=$('#goods_img').find('img[src="/static/img/star_light.png"]').length;
	
	
	aa.pack_grade=$('#shangpingbaozhuang').find('img[src="/static/img/star_light.png"]').length;
	aa.speed_grade=$('#songhuosudu').find('img[src="/static/img/star_light.png"]').length;
	aa.dist_grade=$('#songhuyuanfuwutaidu').find('img[src="/static/img/star_light.png"]').length;
	
	dopost(url,aa,function(rs){
		if(rs.wx_id==openid){
			toastwithaction("评价成功",function(){
				history.back(-1);
			});
		}
	});
	
	
}

</script>



</body>